<!DOCTYPE html>
<html>
<head>
    <%
    var title = "注册";
    if(queryData.id)
        title = "修改";
    %>
    <% include common/meta.ejs %>
    <title>用户<%= title %></title>
    <% include common/public.ejs %>
    <style>
        .weui_cell span {
            font-weight: 700;
            padding-right: 1.5rem;
        }

        .weui_cell input {
            border-bottom: #666 1px solid;
        }

        .div_msxx {
            margin: 0.5rem;
            color: #a8a8a8;
            font: .875em/100% Arial, Helvetica, sans-serif;
        }

        .weui_cells {
            margin-top: 0.5rem;
        }

        .weui_input {
            width: 90%;
        }

        .weui_cells_form .weui_icon_warn {
            float: right;
        }

        .hidden {
            display: none;
        }

        .weui-vcode-btn {
            height: 30px;
            width: 100%;
            border: 0;
        }
        .sel_btn {
            border: 0;
            background-color: #ebe7e4;
            color: #333;
            font-size: 18px;
            padding: 10px;
            margin: 10px 0;
            display: block;
            text-align: center;
        }
    </style>
</head>
<body ontouchstart>
<form id="editForm">
    <input type="hidden" name="id" value="<%= data.id %>"/>
    <!--<input type="hidden" name="code" value="<%= session.openId %>"/>-->
    <input type="hidden" name="weChat" value="<%= session.openId %>"/>
    <input type="hidden" name="status" value="3" />
    <input type="hidden" name="userType" value="2" />
    <input type="hidden" name="certification" value="0" />
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <span>真实姓名</span>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text"
                       placeholder="请填写真实姓名" required="required"
                       name="name" value="<%= data.name %>"/>
                <i class="weui_icon_warn"></i>
            </div>
        </div>
    </div>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <span>证件号码</span>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text"
                       placeholder="可为空"
                       name="idCard" value="<%= data.idCard %>"/>
                <i class="weui_icon_warn"></i>
            </div>
        </div>
    </div>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <span>联系电话</span>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="tel"
                       placeholder="请填写联系手机" required="required"
                       name="phone" value="<%= data.phone %>"/>
                <i class="weui_icon_warn"></i>
            </div>
        </div>
    </div>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <span>您的性别</span>
            <div class="weui_cell_bd weui_cell_primary">
                <select name="sex" style="width: 80%;height: 1.3rem;font-size: 0.7rem;">
                    <option value="男" <%= data.sex=='男'?'selected':'' %> >男</option>
                    <option value="女" <%= data.sex=='女'?'selected':'' %> >女</option>
                </select>
                <i class="weui_icon_warn"></i>
            </div>
        </div>
    </div>
    <!--<div class="weui_cells weui_cells_form">-->
        <!--<div class="weui_cell">-->
            <!--<span>邮箱地址</span>-->
            <!--<div class="weui_cell_bd weui_cell_primary">-->
                <!--<input class="weui_input" type="email"-->
                       <!--placeholder="请填写您的邮箱" required="required"-->
                       <!--name="email" value=""/>-->
                <!--<i class="weui_icon_warn"></i>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="weui_cells weui_cells_form">-->
        <!--<div class="weui_cell">-->
            <!--<div class="weui_cell_bd weui_cell_primary">-->
                <!--<input class="weui_input" type="text" id="vcodeInput" placeholder="短信验证码" name="vcode"/>-->
            <!--</div>-->
            <!--<div class="weui-cell__ft" style="width: 30%;">-->
                <!--<button type="button" class="weui-vcode-btn" id="smsSendBtn">获取验证码-->
                <!--</button>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <div class="weui_cells weui_cells_form">
        <a id="submit" href="javascript:submitData();" class="weui_btn weui_btn_warn submit-btn">提交<%=title %></a>
    </div>
    <div style="padding: 1rem 0.5rem;">
        <a style="color: #333;font-size: 1rem;" class="pull-right" href="bindUser">
            <i class="fa fa-mobile-phone fa-lg"></i><span>快速绑定</span>
        </a>
    </div>
</form>
<% include common/footer.ejs %>
<script>

    "use strict";
    function submitData() {
        $(".weui_icon_warn").hide();
        let flag = true;
        $('.weui_input').each(function () {
            if ($(this).attr('required') && !$(this).val()) {
                $(this).siblings('.weui_icon_warn').show();
                flag = false;
            }
        });
        if (flag) {
            $.showLoading("验证中......");
            let data = Dolphin.form.getValue('#editForm');
            Dolphin.ajax({
                url: '<%= global.config.contextPath == '/' ? '' : global.config.contextPath %>/api/8f7def63cc5845468b2c65a69abb0664',
                type: Dolphin.requestMethod.PUT,
                data: Dolphin.json2string(data),
                forceUrl: true,
                onSuccess: function (reData) {
                    Dolphin.ajax({
                        url: '<%= global.config.contextPath == '/' ? '' : global.config.contextPath %>/refresh/session',
                        type: Dolphin.requestMethod.GET,
                        forceUrl: true,
                        onSuccess: function (reData) {
                            location.href = "account?openId=<%= userData.openid %>";
                        }
                    });
                },
                onComplete: function () {
                    $.hideLoading();
                }
            });
        }
    }
</script>
</body>
</html>
